package com.bodacn.keypoint.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bodacn.keypoint.R;
import com.bodacn.keypoint.bean.CutStation;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by KangJunjie on 2020/6/18.
 */
public class StationAdapter extends BaseAdapter {
    private Context context;
    private List<CutStation> dataBeans;

    public StationAdapter(Context context, List<CutStation> beanList) {
        this.context = context;
        this.dataBeans = beanList;
    }

    @Override
    public int getCount() {
        return dataBeans.size();
    }

    @Override
    public Object getItem(int position) {
        return dataBeans.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_cloth_piece_gr, parent, false);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.tvPartName.setText(dataBeans.get(position).getCutName());
        return convertView;
    }



    class ViewHolder {
        @BindView(R.id.tv_PartName)
        TextView tvPartName;
        @BindView(R.id.mylistitem)
        LinearLayout mylistitem;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
